package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 房间合同签约状态的枚举值
 * 待甲方签约 |待乙方签约  |已签约
 */
@Getter
@AllArgsConstructor
public enum ContractSignStatusEnum {
    /**
     * 待甲方签约
     */
    SIGNED_PARTY_A("signed_party_a","待甲方签约"),
    /**
     * 待乙方签约
     */
    SIGNED_PARTY_B("signed_party_b","待乙方签约"),
    /**
     * 已签约
     */
    SIGNED("signed","已签约");


    private String code;
    private String msg;

    private static Map<String, ContractSignStatusEnum> enumMap = new HashMap<>();
    static {
        ContractSignStatusEnum[] values = ContractSignStatusEnum.values();
        for (ContractSignStatusEnum value : values) {
            enumMap.put(value.getCode(), value);
        }
    }
    public static ContractSignStatusEnum getEnum(String num){
        return enumMap.get(num);
    }

    public static ContractSignStatusEnum getContractSignStatusByCode(String code) {
        ContractSignStatusEnum[] contractSignStatusEnums = values();
        for (ContractSignStatusEnum contractSignStatusEnum : contractSignStatusEnums) {
            if (contractSignStatusEnum.code.equals(code)) {
                return contractSignStatusEnum;
            }
        }
        return null;
    }
}
